The Concept arrays, Data types


Description:

The concept arrays are a little bit different. The arrays are organized into vectorial finite structures contained by blocks (about 8000 elements per block). The blocks are then linked into a single linked list, providing this way the speed of a normal array, but the flexibility of a dynamic list. Also can have string keys that will be indexed used a binary search algorithm to provide the best speed. Note that binary search is not the best for sorting, but in this case is the best for adding elements to an array. An array can be retrieved by using the [] operator.

You can allocate arrays three ways:
1)    var[] arr;            // standard (also dynamically allocated)
2)    var arr=new [];    // dynamically alocated
3)    var arr=[1,2,3];    // by providing its values

Using indexes

    var[] arr;
    arr[5]="test";

    Will result in allocating 6 elements in to the given array (0 to 5). The array will look like this: [0,0,0,0,0,"test"]

As you noticed, the concept arrays are not homogeneous. This means you can add virtually anything to an array, but two different elements can contain different data types.

Example:
    arr[0]=5;            // a number
    arr[1]="test";            // a string
    arr[2]=new SomeClass()    // a class
    arr[3]=Foo;            // where Foo is a function in the current class, a delegate
    arr[4]=new [];            // another array


An array can also use string keys:
    arr["test"]="some element";
    arr["another test"]="some other element";
    var key="test3";
    arr[key]="some other other element"

The keys should be readable strings (null terminated). If your string contains a null character, the key will end at that point. In the last example there were 3 elements added, linked string keys. You can also reference them using number indexes, where 0 is the index of the first added string.

    arr[0]    will be the same with arr["test"]
    arr[1]    will be the same with arr["another test"]
    arr[2]    will be the same with arr["test3"]